/* 
 * File:   Log.h
 * Author: mori
 *
 * Created on April 29, 2011, 4:33 PM
 */



#ifndef LOG_H
#define	LOG_H

#include <cstdlib>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <matrix.h>

#include "Grid.h"
#include "Constants.h"
#include "Psi.h"
#include "Parameters.h"
extern Psi* psi;
extern Parameters* ppmts;


#ifndef _NO_NAMESPACE
using namespace std;
using namespace math;
#define STD std
#else
#define STD
#endif

#ifndef _NO_TEMPLATE
typedef matrix<float> Matrix;
#else
typedef matrix Matrix;
#endif

#ifndef _NO_EXCEPTION
#define TRYBEGIN()	try {
#define CATCHERROR()	} catch (const STD::exception& e) { \
						cerr << "Error: " << e.what() << endl; }
#else
#define TRYBEGIN()
#define CATCHERROR()
#endif


class Log {
  public: 
     Log(const char * file_name, const char* path);
     ~Log();
     
     void writeMsg(const char* str);
     void writeErr(const char* str);
     void writeInFile(const char* f_name, float** t, Grid* grid);
     void writeInFile(const char* f_name, int iter_num, float** t, Grid* grid);
     void writeInFile(const char* f_name, Matrix m);
     void writeInFile(const char* f_name, int iter_num, Matrix m);
     const char* getFilePath();
private:
   FILE* its_file_name;
   const char* its_dir;
   const char* its_path;
   const char* its_ext;
     
};


#endif	/* LOG_H */

